<?php


abstract class BaseRingtone extends BaseObject  implements Persistent {


	
	protected static $peer;


	
	protected $id;


	
	protected $name;


	
	protected $avatar_path;


	
	protected $file_path_mp3;


	
	protected $file_path_wav;


	
	protected $duration;


	
	protected $category_id;


	
	protected $creator_id;


	
	protected $creator_name = 'vodanh_';


	
	protected $created_datetime;


	
	protected $rt_status = 0;


	
	protected $rbt_status = 0;


	
	protected $composer_id;


	
	protected $composer_name;


	
	protected $composed_by_user = 1;


	
	protected $checknum;


	
	protected $total_set = 0;


	
	protected $total_download;


	
	protected $bonus_set;


	
	protected $bonus_download;


	
	protected $update_type;


	
	protected $last_update_datetime;

	
	protected $aUser;

	
	protected $aRingtoneCategory;

	
	protected $collRingtoneStatuss;

	
	protected $lastRingtoneStatusCriteria = null;

	
	protected $alreadyInSave = false;

	
	protected $alreadyInValidation = false;

	
	public function getId()
	{

		return $this->id;
	}

	
	public function getName()
	{

		return $this->name;
	}

	
	public function getAvatarPath()
	{

		return $this->avatar_path;
	}

	
	public function getFilePathMp3()
	{

		return $this->file_path_mp3;
	}

	
	public function getFilePathWav()
	{

		return $this->file_path_wav;
	}

	
	public function getDuration()
	{

		return $this->duration;
	}

	
	public function getCategoryId()
	{

		return $this->category_id;
	}

	
	public function getCreatorId()
	{

		return $this->creator_id;
	}

	
	public function getCreatorName()
	{

		return $this->creator_name;
	}

	
	public function getCreatedDatetime($format = 'Y-m-d H:i:s')
	{

		if ($this->created_datetime === null || $this->created_datetime === '') {
			return null;
		} elseif (!is_int($this->created_datetime)) {
						$ts = strtotime($this->created_datetime);
			if ($ts === -1 || $ts === false) { 				throw new PropelException("Unable to parse value of [created_datetime] as date/time value: " . var_export($this->created_datetime, true));
			}
		} else {
			$ts = $this->created_datetime;
		}
		if ($format === null) {
			return $ts;
		} elseif (strpos($format, '%') !== false) {
			return strftime($format, $ts);
		} else {
			return date($format, $ts);
		}
	}

	
	public function getRtStatus()
	{

		return $this->rt_status;
	}

	
	public function getRbtStatus()
	{

		return $this->rbt_status;
	}

	
	public function getComposerId()
	{

		return $this->composer_id;
	}

	
	public function getComposerName()
	{

		return $this->composer_name;
	}

	
	public function getComposedByUser()
	{

		return $this->composed_by_user;
	}

	
	public function getChecknum()
	{

		return $this->checknum;
	}

	
	public function getTotalSet()
	{

		return $this->total_set;
	}

	
	public function getTotalDownload()
	{

		return $this->total_download;
	}

	
	public function getBonusSet()
	{

		return $this->bonus_set;
	}

	
	public function getBonusDownload()
	{

		return $this->bonus_download;
	}

	
	public function getUpdateType()
	{

		return $this->update_type;
	}

	
	public function getLastUpdateDatetime($format = 'Y-m-d H:i:s')
	{

		if ($this->last_update_datetime === null || $this->last_update_datetime === '') {
			return null;
		} elseif (!is_int($this->last_update_datetime)) {
						$ts = strtotime($this->last_update_datetime);
			if ($ts === -1 || $ts === false) { 				throw new PropelException("Unable to parse value of [last_update_datetime] as date/time value: " . var_export($this->last_update_datetime, true));
			}
		} else {
			$ts = $this->last_update_datetime;
		}
		if ($format === null) {
			return $ts;
		} elseif (strpos($format, '%') !== false) {
			return strftime($format, $ts);
		} else {
			return date($format, $ts);
		}
	}

	
	public function setId($v)
	{

		
		
		if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->id !== $v) {
			$this->id = $v;
			$this->modifiedColumns[] = RingtonePeer::ID;
		}

	} 
	
	public function setName($v)
	{

		
		
		if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->name !== $v) {
			$this->name = $v;
			$this->modifiedColumns[] = RingtonePeer::NAME;
		}

	} 
	
	public function setAvatarPath($v)
	{

		
		
		if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->avatar_path !== $v) {
			$this->avatar_path = $v;
			$this->modifiedColumns[] = RingtonePeer::AVATAR_PATH;
		}

	} 
	
	public function setFilePathMp3($v)
	{

		
		
		if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->file_path_mp3 !== $v) {
			$this->file_path_mp3 = $v;
			$this->modifiedColumns[] = RingtonePeer::FILE_PATH_MP3;
		}

	} 
	
	public function setFilePathWav($v)
	{

		
		
		if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->file_path_wav !== $v) {
			$this->file_path_wav = $v;
			$this->modifiedColumns[] = RingtonePeer::FILE_PATH_WAV;
		}

	} 
	
	public function setDuration($v)
	{

		
		
		if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->duration !== $v) {
			$this->duration = $v;
			$this->modifiedColumns[] = RingtonePeer::DURATION;
		}

	} 
	
	public function setCategoryId($v)
	{

		
		
		if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->category_id !== $v) {
			$this->category_id = $v;
			$this->modifiedColumns[] = RingtonePeer::CATEGORY_ID;
		}

		if ($this->aRingtoneCategory !== null && $this->aRingtoneCategory->getId() !== $v) {
			$this->aRingtoneCategory = null;
		}

	} 
	
	public function setCreatorId($v)
	{

		
		
		if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->creator_id !== $v) {
			$this->creator_id = $v;
			$this->modifiedColumns[] = RingtonePeer::CREATOR_ID;
		}

		if ($this->aUser !== null && $this->aUser->getId() !== $v) {
			$this->aUser = null;
		}

	} 
	
	public function setCreatorName($v)
	{

		
		
		if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->creator_name !== $v || $v === 'vodanh_') {
			$this->creator_name = $v;
			$this->modifiedColumns[] = RingtonePeer::CREATOR_NAME;
		}

	} 
	
	public function setCreatedDatetime($v)
	{

		if ($v !== null && !is_int($v)) {
			$ts = strtotime($v);
			if ($ts === -1 || $ts === false) { 				throw new PropelException("Unable to parse date/time value for [created_datetime] from input: " . var_export($v, true));
			}
		} else {
			$ts = $v;
		}
		if ($this->created_datetime !== $ts) {
			$this->created_datetime = $ts;
			$this->modifiedColumns[] = RingtonePeer::CREATED_DATETIME;
		}

	} 
	
	public function setRtStatus($v)
	{

		
		
		if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->rt_status !== $v || $v === 0) {
			$this->rt_status = $v;
			$this->modifiedColumns[] = RingtonePeer::RT_STATUS;
		}

	} 
	
	public function setRbtStatus($v)
	{

		
		
		if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->rbt_status !== $v || $v === 0) {
			$this->rbt_status = $v;
			$this->modifiedColumns[] = RingtonePeer::RBT_STATUS;
		}

	} 
	
	public function setComposerId($v)
	{

		
		
		if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->composer_id !== $v) {
			$this->composer_id = $v;
			$this->modifiedColumns[] = RingtonePeer::COMPOSER_ID;
		}

	} 
	
	public function setComposerName($v)
	{

		
		
		if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->composer_name !== $v) {
			$this->composer_name = $v;
			$this->modifiedColumns[] = RingtonePeer::COMPOSER_NAME;
		}

	} 
	
	public function setComposedByUser($v)
	{

		
		
		if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->composed_by_user !== $v || $v === 1) {
			$this->composed_by_user = $v;
			$this->modifiedColumns[] = RingtonePeer::COMPOSED_BY_USER;
		}

	} 
	
	public function setChecknum($v)
	{

		
		
		if ($v !== null && !is_string($v)) {
			$v = (string) $v; 
		}

		if ($this->checknum !== $v) {
			$this->checknum = $v;
			$this->modifiedColumns[] = RingtonePeer::CHECKNUM;
		}

	} 
	
	public function setTotalSet($v)
	{

		
		
		if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->total_set !== $v || $v === 0) {
			$this->total_set = $v;
			$this->modifiedColumns[] = RingtonePeer::TOTAL_SET;
		}

	} 
	
	public function setTotalDownload($v)
	{

		
		
		if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->total_download !== $v) {
			$this->total_download = $v;
			$this->modifiedColumns[] = RingtonePeer::TOTAL_DOWNLOAD;
		}

	} 
	
	public function setBonusSet($v)
	{

		
		
		if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->bonus_set !== $v) {
			$this->bonus_set = $v;
			$this->modifiedColumns[] = RingtonePeer::BONUS_SET;
		}

	} 
	
	public function setBonusDownload($v)
	{

		
		
		if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->bonus_download !== $v) {
			$this->bonus_download = $v;
			$this->modifiedColumns[] = RingtonePeer::BONUS_DOWNLOAD;
		}

	} 
	
	public function setUpdateType($v)
	{

		
		
		if ($v !== null && !is_int($v) && is_numeric($v)) {
			$v = (int) $v;
		}

		if ($this->update_type !== $v) {
			$this->update_type = $v;
			$this->modifiedColumns[] = RingtonePeer::UPDATE_TYPE;
		}

	} 
	
	public function setLastUpdateDatetime($v)
	{

		if ($v !== null && !is_int($v)) {
			$ts = strtotime($v);
			if ($ts === -1 || $ts === false) { 				throw new PropelException("Unable to parse date/time value for [last_update_datetime] from input: " . var_export($v, true));
			}
		} else {
			$ts = $v;
		}
		if ($this->last_update_datetime !== $ts) {
			$this->last_update_datetime = $ts;
			$this->modifiedColumns[] = RingtonePeer::LAST_UPDATE_DATETIME;
		}

	} 
	
	public function hydrate(ResultSet $rs, $startcol = 1)
	{
		try {

			$this->id = $rs->getInt($startcol + 0);

			$this->name = $rs->getString($startcol + 1);

			$this->avatar_path = $rs->getString($startcol + 2);

			$this->file_path_mp3 = $rs->getString($startcol + 3);

			$this->file_path_wav = $rs->getString($startcol + 4);

			$this->duration = $rs->getInt($startcol + 5);

			$this->category_id = $rs->getInt($startcol + 6);

			$this->creator_id = $rs->getInt($startcol + 7);

			$this->creator_name = $rs->getString($startcol + 8);

			$this->created_datetime = $rs->getTimestamp($startcol + 9, null);

			$this->rt_status = $rs->getInt($startcol + 10);

			$this->rbt_status = $rs->getInt($startcol + 11);

			$this->composer_id = $rs->getInt($startcol + 12);

			$this->composer_name = $rs->getString($startcol + 13);

			$this->composed_by_user = $rs->getInt($startcol + 14);

			$this->checknum = $rs->getString($startcol + 15);

			$this->total_set = $rs->getInt($startcol + 16);

			$this->total_download = $rs->getInt($startcol + 17);

			$this->bonus_set = $rs->getInt($startcol + 18);

			$this->bonus_download = $rs->getInt($startcol + 19);

			$this->update_type = $rs->getInt($startcol + 20);

			$this->last_update_datetime = $rs->getTimestamp($startcol + 21, null);

			$this->resetModified();

			$this->setNew(false);

						return $startcol + 22; 
		} catch (Exception $e) {
			throw new PropelException("Error populating Ringtone object", $e);
		}
	}

	
	public function delete($con = null)
	{
		if ($this->isDeleted()) {
			throw new PropelException("This object has already been deleted.");
		}

		if ($con === null) {
			$con = Propel::getConnection(RingtonePeer::DATABASE_NAME);
		}

		try {
			$con->begin();
			RingtonePeer::doDelete($this, $con);
			$this->setDeleted(true);
			$con->commit();
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	
	public function save($con = null)
	{
		if ($this->isDeleted()) {
			throw new PropelException("You cannot save an object that has been deleted.");
		}

		if ($con === null) {
			$con = Propel::getConnection(RingtonePeer::DATABASE_NAME);
		}

		try {
			$con->begin();
			$affectedRows = $this->doSave($con);
			$con->commit();
			return $affectedRows;
		} catch (PropelException $e) {
			$con->rollback();
			throw $e;
		}
	}

	
	protected function doSave($con)
	{
		$affectedRows = 0; 		if (!$this->alreadyInSave) {
			$this->alreadyInSave = true;


												
			if ($this->aUser !== null) {
				if ($this->aUser->isModified()) {
					$affectedRows += $this->aUser->save($con);
				}
				$this->setUser($this->aUser);
			}

			if ($this->aRingtoneCategory !== null) {
				if ($this->aRingtoneCategory->isModified()) {
					$affectedRows += $this->aRingtoneCategory->save($con);
				}
				$this->setRingtoneCategory($this->aRingtoneCategory);
			}


						if ($this->isModified()) {
				if ($this->isNew()) {
					$pk = RingtonePeer::doInsert($this, $con);
					$affectedRows += 1; 										 										 
					$this->setId($pk);  
					$this->setNew(false);
				} else {
					$affectedRows += RingtonePeer::doUpdate($this, $con);
				}
				$this->resetModified(); 			}

			if ($this->collRingtoneStatuss !== null) {
				foreach($this->collRingtoneStatuss as $referrerFK) {
					if (!$referrerFK->isDeleted()) {
						$affectedRows += $referrerFK->save($con);
					}
				}
			}

			$this->alreadyInSave = false;
		}
		return $affectedRows;
	} 
	
	protected $validationFailures = array();

	
	public function getValidationFailures()
	{
		return $this->validationFailures;
	}

	
	public function validate($columns = null)
	{
		$res = $this->doValidate($columns);
		if ($res === true) {
			$this->validationFailures = array();
			return true;
		} else {
			$this->validationFailures = $res;
			return false;
		}
	}

	
	protected function doValidate($columns = null)
	{
		if (!$this->alreadyInValidation) {
			$this->alreadyInValidation = true;
			$retval = null;

			$failureMap = array();


												
			if ($this->aUser !== null) {
				if (!$this->aUser->validate($columns)) {
					$failureMap = array_merge($failureMap, $this->aUser->getValidationFailures());
				}
			}

			if ($this->aRingtoneCategory !== null) {
				if (!$this->aRingtoneCategory->validate($columns)) {
					$failureMap = array_merge($failureMap, $this->aRingtoneCategory->getValidationFailures());
				}
			}


			if (($retval = RingtonePeer::doValidate($this, $columns)) !== true) {
				$failureMap = array_merge($failureMap, $retval);
			}


				if ($this->collRingtoneStatuss !== null) {
					foreach($this->collRingtoneStatuss as $referrerFK) {
						if (!$referrerFK->validate($columns)) {
							$failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
						}
					}
				}


			$this->alreadyInValidation = false;
		}

		return (!empty($failureMap) ? $failureMap : true);
	}

	
	public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
	{
		$pos = RingtonePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
		return $this->getByPosition($pos);
	}

	
	public function getByPosition($pos)
	{
		switch($pos) {
			case 0:
				return $this->getId();
				break;
			case 1:
				return $this->getName();
				break;
			case 2:
				return $this->getAvatarPath();
				break;
			case 3:
				return $this->getFilePathMp3();
				break;
			case 4:
				return $this->getFilePathWav();
				break;
			case 5:
				return $this->getDuration();
				break;
			case 6:
				return $this->getCategoryId();
				break;
			case 7:
				return $this->getCreatorId();
				break;
			case 8:
				return $this->getCreatorName();
				break;
			case 9:
				return $this->getCreatedDatetime();
				break;
			case 10:
				return $this->getRtStatus();
				break;
			case 11:
				return $this->getRbtStatus();
				break;
			case 12:
				return $this->getComposerId();
				break;
			case 13:
				return $this->getComposerName();
				break;
			case 14:
				return $this->getComposedByUser();
				break;
			case 15:
				return $this->getChecknum();
				break;
			case 16:
				return $this->getTotalSet();
				break;
			case 17:
				return $this->getTotalDownload();
				break;
			case 18:
				return $this->getBonusSet();
				break;
			case 19:
				return $this->getBonusDownload();
				break;
			case 20:
				return $this->getUpdateType();
				break;
			case 21:
				return $this->getLastUpdateDatetime();
				break;
			default:
				return null;
				break;
		} 	}

	
	public function toArray($keyType = BasePeer::TYPE_PHPNAME)
	{
		$keys = RingtonePeer::getFieldNames($keyType);
		$result = array(
			$keys[0] => $this->getId(),
			$keys[1] => $this->getName(),
			$keys[2] => $this->getAvatarPath(),
			$keys[3] => $this->getFilePathMp3(),
			$keys[4] => $this->getFilePathWav(),
			$keys[5] => $this->getDuration(),
			$keys[6] => $this->getCategoryId(),
			$keys[7] => $this->getCreatorId(),
			$keys[8] => $this->getCreatorName(),
			$keys[9] => $this->getCreatedDatetime(),
			$keys[10] => $this->getRtStatus(),
			$keys[11] => $this->getRbtStatus(),
			$keys[12] => $this->getComposerId(),
			$keys[13] => $this->getComposerName(),
			$keys[14] => $this->getComposedByUser(),
			$keys[15] => $this->getChecknum(),
			$keys[16] => $this->getTotalSet(),
			$keys[17] => $this->getTotalDownload(),
			$keys[18] => $this->getBonusSet(),
			$keys[19] => $this->getBonusDownload(),
			$keys[20] => $this->getUpdateType(),
			$keys[21] => $this->getLastUpdateDatetime(),
		);
		return $result;
	}

	
	public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
	{
		$pos = RingtonePeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
		return $this->setByPosition($pos, $value);
	}

	
	public function setByPosition($pos, $value)
	{
		switch($pos) {
			case 0:
				$this->setId($value);
				break;
			case 1:
				$this->setName($value);
				break;
			case 2:
				$this->setAvatarPath($value);
				break;
			case 3:
				$this->setFilePathMp3($value);
				break;
			case 4:
				$this->setFilePathWav($value);
				break;
			case 5:
				$this->setDuration($value);
				break;
			case 6:
				$this->setCategoryId($value);
				break;
			case 7:
				$this->setCreatorId($value);
				break;
			case 8:
				$this->setCreatorName($value);
				break;
			case 9:
				$this->setCreatedDatetime($value);
				break;
			case 10:
				$this->setRtStatus($value);
				break;
			case 11:
				$this->setRbtStatus($value);
				break;
			case 12:
				$this->setComposerId($value);
				break;
			case 13:
				$this->setComposerName($value);
				break;
			case 14:
				$this->setComposedByUser($value);
				break;
			case 15:
				$this->setChecknum($value);
				break;
			case 16:
				$this->setTotalSet($value);
				break;
			case 17:
				$this->setTotalDownload($value);
				break;
			case 18:
				$this->setBonusSet($value);
				break;
			case 19:
				$this->setBonusDownload($value);
				break;
			case 20:
				$this->setUpdateType($value);
				break;
			case 21:
				$this->setLastUpdateDatetime($value);
				break;
		} 	}

	
	public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
	{
		$keys = RingtonePeer::getFieldNames($keyType);

		if (array_key_exists($keys[0], $arr)) $this->setId($arr[$keys[0]]);
		if (array_key_exists($keys[1], $arr)) $this->setName($arr[$keys[1]]);
		if (array_key_exists($keys[2], $arr)) $this->setAvatarPath($arr[$keys[2]]);
		if (array_key_exists($keys[3], $arr)) $this->setFilePathMp3($arr[$keys[3]]);
		if (array_key_exists($keys[4], $arr)) $this->setFilePathWav($arr[$keys[4]]);
		if (array_key_exists($keys[5], $arr)) $this->setDuration($arr[$keys[5]]);
		if (array_key_exists($keys[6], $arr)) $this->setCategoryId($arr[$keys[6]]);
		if (array_key_exists($keys[7], $arr)) $this->setCreatorId($arr[$keys[7]]);
		if (array_key_exists($keys[8], $arr)) $this->setCreatorName($arr[$keys[8]]);
		if (array_key_exists($keys[9], $arr)) $this->setCreatedDatetime($arr[$keys[9]]);
		if (array_key_exists($keys[10], $arr)) $this->setRtStatus($arr[$keys[10]]);
		if (array_key_exists($keys[11], $arr)) $this->setRbtStatus($arr[$keys[11]]);
		if (array_key_exists($keys[12], $arr)) $this->setComposerId($arr[$keys[12]]);
		if (array_key_exists($keys[13], $arr)) $this->setComposerName($arr[$keys[13]]);
		if (array_key_exists($keys[14], $arr)) $this->setComposedByUser($arr[$keys[14]]);
		if (array_key_exists($keys[15], $arr)) $this->setChecknum($arr[$keys[15]]);
		if (array_key_exists($keys[16], $arr)) $this->setTotalSet($arr[$keys[16]]);
		if (array_key_exists($keys[17], $arr)) $this->setTotalDownload($arr[$keys[17]]);
		if (array_key_exists($keys[18], $arr)) $this->setBonusSet($arr[$keys[18]]);
		if (array_key_exists($keys[19], $arr)) $this->setBonusDownload($arr[$keys[19]]);
		if (array_key_exists($keys[20], $arr)) $this->setUpdateType($arr[$keys[20]]);
		if (array_key_exists($keys[21], $arr)) $this->setLastUpdateDatetime($arr[$keys[21]]);
	}

	
	public function buildCriteria()
	{
		$criteria = new Criteria(RingtonePeer::DATABASE_NAME);

		if ($this->isColumnModified(RingtonePeer::ID)) $criteria->add(RingtonePeer::ID, $this->id);
		if ($this->isColumnModified(RingtonePeer::NAME)) $criteria->add(RingtonePeer::NAME, $this->name);
		if ($this->isColumnModified(RingtonePeer::AVATAR_PATH)) $criteria->add(RingtonePeer::AVATAR_PATH, $this->avatar_path);
		if ($this->isColumnModified(RingtonePeer::FILE_PATH_MP3)) $criteria->add(RingtonePeer::FILE_PATH_MP3, $this->file_path_mp3);
		if ($this->isColumnModified(RingtonePeer::FILE_PATH_WAV)) $criteria->add(RingtonePeer::FILE_PATH_WAV, $this->file_path_wav);
		if ($this->isColumnModified(RingtonePeer::DURATION)) $criteria->add(RingtonePeer::DURATION, $this->duration);
		if ($this->isColumnModified(RingtonePeer::CATEGORY_ID)) $criteria->add(RingtonePeer::CATEGORY_ID, $this->category_id);
		if ($this->isColumnModified(RingtonePeer::CREATOR_ID)) $criteria->add(RingtonePeer::CREATOR_ID, $this->creator_id);
		if ($this->isColumnModified(RingtonePeer::CREATOR_NAME)) $criteria->add(RingtonePeer::CREATOR_NAME, $this->creator_name);
		if ($this->isColumnModified(RingtonePeer::CREATED_DATETIME)) $criteria->add(RingtonePeer::CREATED_DATETIME, $this->created_datetime);
		if ($this->isColumnModified(RingtonePeer::RT_STATUS)) $criteria->add(RingtonePeer::RT_STATUS, $this->rt_status);
		if ($this->isColumnModified(RingtonePeer::RBT_STATUS)) $criteria->add(RingtonePeer::RBT_STATUS, $this->rbt_status);
		if ($this->isColumnModified(RingtonePeer::COMPOSER_ID)) $criteria->add(RingtonePeer::COMPOSER_ID, $this->composer_id);
		if ($this->isColumnModified(RingtonePeer::COMPOSER_NAME)) $criteria->add(RingtonePeer::COMPOSER_NAME, $this->composer_name);
		if ($this->isColumnModified(RingtonePeer::COMPOSED_BY_USER)) $criteria->add(RingtonePeer::COMPOSED_BY_USER, $this->composed_by_user);
		if ($this->isColumnModified(RingtonePeer::CHECKNUM)) $criteria->add(RingtonePeer::CHECKNUM, $this->checknum);
		if ($this->isColumnModified(RingtonePeer::TOTAL_SET)) $criteria->add(RingtonePeer::TOTAL_SET, $this->total_set);
		if ($this->isColumnModified(RingtonePeer::TOTAL_DOWNLOAD)) $criteria->add(RingtonePeer::TOTAL_DOWNLOAD, $this->total_download);
		if ($this->isColumnModified(RingtonePeer::BONUS_SET)) $criteria->add(RingtonePeer::BONUS_SET, $this->bonus_set);
		if ($this->isColumnModified(RingtonePeer::BONUS_DOWNLOAD)) $criteria->add(RingtonePeer::BONUS_DOWNLOAD, $this->bonus_download);
		if ($this->isColumnModified(RingtonePeer::UPDATE_TYPE)) $criteria->add(RingtonePeer::UPDATE_TYPE, $this->update_type);
		if ($this->isColumnModified(RingtonePeer::LAST_UPDATE_DATETIME)) $criteria->add(RingtonePeer::LAST_UPDATE_DATETIME, $this->last_update_datetime);

		return $criteria;
	}

	
	public function buildPkeyCriteria()
	{
		$criteria = new Criteria(RingtonePeer::DATABASE_NAME);

		$criteria->add(RingtonePeer::ID, $this->id);

		return $criteria;
	}

	
	public function getPrimaryKey()
	{
		return $this->getId();
	}

	
	public function setPrimaryKey($key)
	{
		$this->setId($key);
	}

	
	public function copyInto($copyObj, $deepCopy = false)
	{

		$copyObj->setName($this->name);

		$copyObj->setAvatarPath($this->avatar_path);

		$copyObj->setFilePathMp3($this->file_path_mp3);

		$copyObj->setFilePathWav($this->file_path_wav);

		$copyObj->setDuration($this->duration);

		$copyObj->setCategoryId($this->category_id);

		$copyObj->setCreatorId($this->creator_id);

		$copyObj->setCreatorName($this->creator_name);

		$copyObj->setCreatedDatetime($this->created_datetime);

		$copyObj->setRtStatus($this->rt_status);

		$copyObj->setRbtStatus($this->rbt_status);

		$copyObj->setComposerId($this->composer_id);

		$copyObj->setComposerName($this->composer_name);

		$copyObj->setComposedByUser($this->composed_by_user);

		$copyObj->setChecknum($this->checknum);

		$copyObj->setTotalSet($this->total_set);

		$copyObj->setTotalDownload($this->total_download);

		$copyObj->setBonusSet($this->bonus_set);

		$copyObj->setBonusDownload($this->bonus_download);

		$copyObj->setUpdateType($this->update_type);

		$copyObj->setLastUpdateDatetime($this->last_update_datetime);


		if ($deepCopy) {
									$copyObj->setNew(false);

			foreach($this->getRingtoneStatuss() as $relObj) {
				$copyObj->addRingtoneStatus($relObj->copy($deepCopy));
			}

		} 

		$copyObj->setNew(true);

		$copyObj->setId(NULL); 
	}

	
	public function copy($deepCopy = false)
	{
				$clazz = get_class($this);
		$copyObj = new $clazz();
		$this->copyInto($copyObj, $deepCopy);
		return $copyObj;
	}

	
	public function getPeer()
	{
		if (self::$peer === null) {
			self::$peer = new RingtonePeer();
		}
		return self::$peer;
	}

	
	public function setUser($v)
	{


		if ($v === null) {
			$this->setCreatorId(NULL);
		} else {
			$this->setCreatorId($v->getId());
		}


		$this->aUser = $v;
	}


	
	public function getUser($con = null)
	{
		if ($this->aUser === null && ($this->creator_id !== null)) {
						include_once 'lib/model/om/BaseUserPeer.php';

			$this->aUser = UserPeer::retrieveByPK($this->creator_id, $con);

			
		}
		return $this->aUser;
	}

	
	public function setRingtoneCategory($v)
	{


		if ($v === null) {
			$this->setCategoryId(NULL);
		} else {
			$this->setCategoryId($v->getId());
		}


		$this->aRingtoneCategory = $v;
	}


	
	public function getRingtoneCategory($con = null)
	{
		if ($this->aRingtoneCategory === null && ($this->category_id !== null)) {
						include_once 'lib/model/om/BaseRingtoneCategoryPeer.php';

			$this->aRingtoneCategory = RingtoneCategoryPeer::retrieveByPK($this->category_id, $con);

			
		}
		return $this->aRingtoneCategory;
	}

	
	public function initRingtoneStatuss()
	{
		if ($this->collRingtoneStatuss === null) {
			$this->collRingtoneStatuss = array();
		}
	}

	
	public function getRingtoneStatuss($criteria = null, $con = null)
	{
				include_once 'lib/model/om/BaseRingtoneStatusPeer.php';
		if ($criteria === null) {
			$criteria = new Criteria();
		}
		elseif ($criteria instanceof Criteria)
		{
			$criteria = clone $criteria;
		}

		if ($this->collRingtoneStatuss === null) {
			if ($this->isNew()) {
			   $this->collRingtoneStatuss = array();
			} else {

				$criteria->add(RingtoneStatusPeer::RINGTONE_ID, $this->getId());

				RingtoneStatusPeer::addSelectColumns($criteria);
				$this->collRingtoneStatuss = RingtoneStatusPeer::doSelect($criteria, $con);
			}
		} else {
						if (!$this->isNew()) {
												

				$criteria->add(RingtoneStatusPeer::RINGTONE_ID, $this->getId());

				RingtoneStatusPeer::addSelectColumns($criteria);
				if (!isset($this->lastRingtoneStatusCriteria) || !$this->lastRingtoneStatusCriteria->equals($criteria)) {
					$this->collRingtoneStatuss = RingtoneStatusPeer::doSelect($criteria, $con);
				}
			}
		}
		$this->lastRingtoneStatusCriteria = $criteria;
		return $this->collRingtoneStatuss;
	}

	
	public function countRingtoneStatuss($criteria = null, $distinct = false, $con = null)
	{
				include_once 'lib/model/om/BaseRingtoneStatusPeer.php';
		if ($criteria === null) {
			$criteria = new Criteria();
		}
		elseif ($criteria instanceof Criteria)
		{
			$criteria = clone $criteria;
		}

		$criteria->add(RingtoneStatusPeer::RINGTONE_ID, $this->getId());

		return RingtoneStatusPeer::doCount($criteria, $distinct, $con);
	}

	
	public function addRingtoneStatus(RingtoneStatus $l)
	{
		$this->collRingtoneStatuss[] = $l;
		$l->setRingtone($this);
	}

} 